package bigdata.mysql;

import java.sql.*;

public class LoginTwo {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        Connection c = DriverManager.getConnection("jdbc:mysql://master:3306/test", "root", "123456");
        String username = "root";
        String sql = "select * from user where username=?";
        //Statement s = c.createStatement();

        PreparedStatement p = c.prepareStatement(sql);
        p.setString(1,username);
        ResultSet r = p.executeQuery();

        if (r.next()){
            System.out.println("登录成功");
        }else {
            System.out.println("登录失败");
        }
        r.close();
        p.close();
        c.close();

    }
}
